<?php
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
cfc('core')->checklogin();
set_html('title','我的订单');
if($_RQ['op']=='main'){
	$member=$this->model('member')->checkmember();
	$member['level']['type']=3;
	$return['setting']=$this->plugin_setting('page');
	$return['params']=array(
		'page'=>1,
	);
	$params=array('merchid'=>$_SESSION['onemerchid'],'uniacid'=>$_SESSION['uniacid']);
	$return['commission_money']=pdo_getsum('jy_weishop_order',$params,'price');
	$return['commission_total']=pdo_count('jy_weishop_order',$params);
	$month_start=strtotime(date('Ym').'01');
	$params['createtime >']=$month_start;
	$return['month_money']=pdo_getsum('jy_weishop_order',$params,'price');
	$return['total_price']=$this->model('model')->goods_allfee($member);
	$return['total_price2']=$this->model('model')->goods_allfee($member,0,1);
	$return['commission_money'] -=$return['total_price'];
	$return['month_money'] -=$return['total_price2'];
	$return['list']=array();
	$return['psize']=20;
	exi($return);
}
if($_RQ['op']=='list'){
	$params=array('merchid'=>$_SESSION['onemerchid']);
	if($_RQ['bumenid']){
		$params['bumenid']=intval($_RQ['bumenid']);
	}
	if($_RQ['workerid']){
		$params['workerid']=intval($_RQ['workerid']);
	}
	$psize=20;
	$pindex=intval($_RQ['page'])?:1;
	$parameter=array(
		'params'=>$params,
		'limit'=>array($pindex,$psize),
		'orderby'=>'id desc',
	);
	$list=pdo_getlist('jy_weishop_order',$parameter);
	if(!$list){
		exi('none');
	}
	foreach($list as &$item){
		$item['member']=model('core/member')->basic($item['mid']);
		$item['goodsid']=pdo_getcolumn('jy_weishop_order_goods',array('orderid'=>$item['id']),'goodsid');
		$item['goodstitle']=pdo_getcolumn('jy_weishop_goods',array('id'=>$item['goodsid']),'title');
		$item['createtime']=date('Y-m-d H:i:s',$item['createtime']);
	}
	exi($list);
}
?>